/*
	cpp_runtime_main.c

	Contains the required C++ runtime functionality for the higher-level kernel code.
	Currently only supports virtual functions and dynamic object allocation.

	Author: Aidan Goddard 16/7/14
*/


#include "types.h"
#include "kernel_fixed_table.h"

extern "C" void *kmalloc(size_t size);
extern "C" void *kcalloc(size_t number_objects, size_t object_size);
extern "C" void *krealloc(void *ptr, size_t size);
extern "C" void kfree(void *ptr);

//////////////////////////////////////////////////////////////////////////////////////////
// new, delete, new[], delete[]

void *operator new(size_t size)
{
	return kmalloc(size);
}
 
void *operator new[](size_t size)
{
    return kmalloc(size);
}
 
void operator delete(void *p)
{
    kfree(p);
	return;
}
 
void operator delete[](void *p)
{
    kfree(p);
	return;
}

//////////////////////////////////////////////////////////////////////////////////////////
// virtual functions